package net.chery.entity;

/**
 * @author gai
 * 包含哪些数据
 * <p>
 * 0001 1
 * <p>
 * 0010 2
 * 0011 3
 * <p>
 * 0100 4
 * 0101 5
 * 0110 6
 * 0111 7
 * <p>
 * 1000 8
 * 1001 9
 * 1010 10
 * 1011 11
 * 1100 12
 * 1101 13
 * 1110 14
 * 1111 15
 */
public enum DataType {
    /**
     * 二进制数据区别
     */
    PRODUCE(new int[]{1,3,5,7,9,11,13,15},1),
    SALE(new int[]{2, 3, 6, 7, 10, 11, 14, 15},2),
    MES(new int[]{4,5,6,7,12,13,14,15},4),
    DMS(new int[]{8, 9, 10, 11, 12, 13, 14, 15},8),;
    private final int[] type;
    private final int add;

    DataType(int[] type,int add) {
        this.type = type;
        this.add = add;
    }

    public int add(int type){
        if(has(type)){
            return type;
        }
        return type+add;
    }

    public boolean has(int type){
        for (int x:this.type){
            if(type==x){
                return true;
            }
        }
        return false;
    }
}